import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * 作者: 俞小洋@2020-06-04
 * 角色和菜单/按钮 解耦, 角色拥有一系列的permissionCode(和菜单路由的path或者按钮的permissionCode具有规则对应关系)
 * 菜单路由和按钮会根据permissionCode来决定是否显示
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * permissionCode                 对于普通路由,无需设置, 对于外部链接路由, 该值会替换path作为permissionCode @yuxiaoyang
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [

  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [{
      path: 'home',
      name: 'Home',
      component: () => import('@/views/home/index'),
      meta: { title: '操作台', icon: 'shouye1' }
    }]
  }
]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [
  /** when your routing map is too long, you can split it into small modules **/


  // 商品管理
  {
    path: '/baseInfoManager',
    component: Layout,
    name: 'BaseInfoManager',
    meta: {
      title: '报销',
      icon: 'home'
      , roles: ['言川一级用户', '言川二级用户', '言川三级用户']
    },
    children: [
      {
        path: 'breedInfo',
        name: '',
        component: () => import('@/views/projectOa/myProject/myProject'),
        meta: {
          title:
            '报销申请',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户']
        }
      },
      {
        path: 'nodeManager',
        name: '',
        component: () => import('@/views/projectOa/myProject/myProject'),
        meta: {
          title: '我的报销',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户']
        }
      }, {
        path: 'nodeManager',
        name: '',
        component: () => import('@/views/projectOa/myProject/myProject'),
        meta: {
          title: '报销审批',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户']
        }
      }, {
        path: 'nodeManager',
        name: '',
        component: () => import('@/views/projectOa/myProject/myProject'),
        meta: {
          title: '报销检索',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户']
        }
      }, {
        path: 'nodeManager',
        name: '',
        component: () => import('@/views/projectOa/myProject/myProject'),
        meta: {
          title: '预算统计',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户']
        }
      }

    ]
  },

  // 摸底信息
  {
    path: '/findOutInformation',
    component: Layout,
    name: 'FindOutInformation',
    meta: {
      title: '办公',
      icon: 'modi'
      , roles: ['言川一级用户', '言川二级用户', '言川三级用户']
    },
    children: [
      {
        path: 'nodeFindOutInformation',
        name: '',
        component: () => import('@/views/projectOa/myProject/myProject'),
        meta: {
          title:
            '我的汇报',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户']
        }
      },
      {
        path: 'countyFindOutInformationSubmit',
        name: '',
        component: () => import('@/views/projectOa/myProject/myProject'),
        meta: {
          title: '日报审批',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户']
        }
      },

      {
        path: 'countyFindOutInformation',
        name: '',
        component: () => import('@/views/projectOa/myProject/myProject'),
        meta: {
          title: '周报批阅',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户']
        }
      },

      {
        path: 'countyFindOutExamineInformation',
        name: '',
        component: () => import('@/views/projectOa/myProject/myProject'),
        meta: {
          title: '月报批阅',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户']
        }
      }, {
        path: 'countyFindOutExamineInformation',
        name: '',
        component: () => import('@/views/projectOa/myProject/myProject'),
        meta: {
          title: '汇报检索',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户']
        }
      }, {
        path: 'countyFindOutExamineInformation',
        name: '',
        component: () => import('@/views/projectOa/myProject/myProject'),
        meta: {
          title: '日报统计',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户']
        }
      }, {
        path: 'countyFindOutExamineInformation',
        name: '',
        component: () => import('@/views/projectOa/myProject/myProject'),
        meta: {
          title: '日报分析',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户']
        }
      }

    ]
  },

  //个人中心
  {
    path: '/userCenter',
    component: Layout,
    name: 'userCenter',
    meta: {
      title: '个人中心',
      icon: 'userCenter'
      , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']
    },
    children: [

      {
        path: 'reimbursement',
        name: '',
        component: () => import('@/views/finance/reimbursement'),
        meta: {
          title: '基础信息',
          icon: 'reimbursement'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']

        }
      },
      {
        path: 'reimbursement',
        name: '',
        component: () => import('@/views/finance/reimbursement'),
        meta: {
          title: '合同信息',
          icon: 'kaoqin'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']

        }
      },

    ]
  },

//考勤&请假
  {
    path: '/attendance',
    component: Layout,
    name: 'attendance',
    meta: {
      title: '考勤&请假',
      icon: 'kaoqinqingjia'
      , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']
    },
    children: [

      {
        path: 'attendanceManage',
        name: '',
        component: () => import('@/views/attendance/attendanceManage'),
        meta: {
          title: '考勤',
          icon: 'kaoqin'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']

        }
      },
      {
        path: 'leaverManage',
        name: '',
        component: () => import('@/views/attendance/leaverManage'),
        meta: {
          title: '请假',
          icon: 'qingjia'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']

        }
      },

    ]
  },


  //日志&外出

  {
    path: '/dayLogs',
    component: Layout,
    name: 'dayLogs',
    meta: {
      title: '日志&外出',
      icon: 'rizhi'
      , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']
    },
    children: [

      {
        path: 'myDayLogs',
        name: '',
        component: () => import('@/views/dayLogs/myDayLogs'),
        meta: {
          title: '日志&外出',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']

        }
      },

      {
        path: 'myProject1',
        name: '',
        component: () => import('@/views/projectOa/myProject/myProject'),
        meta: {
          title: '日志审批',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户', , 'oa管理员']

        }
      }, {
        path: 'myProject2',
        name: '',
        component: () => import('@/views/projectOa/myProject/myProject'),
        meta: {
          title: '日志检索',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户', , 'oa管理员']

        }
      }, {
        path: 'myProject3',
        name: '',
        component: () => import('@/views/projectOa/myProject/myProject'),
        meta: {
          title: '日志统计',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户', , 'oa管理员']

        }
      },

    ]
  },

  //财务
  {
    path: '/finance',
    component: Layout,
    name: 'finance',
    meta: {
      title: '财务',
      icon: 'finance'
      , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']
    },
    children: [

      {
        path: 'reimbursement',
        name: '',
        component: () => import('@/views/finance/reimbursement'),
        meta: {
          title: '报销',
          icon: 'reimbursement'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']

        }
      },
      {
        path: 'reimbursement',
        name: '',
        component: () => import('@/views/finance/reimbursement'),
        meta: {
          title: '报销',
          icon: 'kaoqin'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']

        }
      },

    ]
  },

  // 项目管理
  {
    path: '/projectOa',
    component: Layout,
    name: 'projectOa',
    meta: {
      title: '项目',
      icon: 'project'
      , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']
    },
    children: [
      {
        path: 'myProject',
        name: '',
        component: () => import('@/views/projectOa/myProject/myProject'),
        meta: {
          title: '我的项目',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']
        }
      },

      {
        path: 'countyAcquisitionStatisticsSubmit',
        name: '',
        component: () => import('@/views/projectOa/myProject/myProject'),
        meta: {
          title: '当前项目',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户', , 'oa管理员']
        }
      },
      {
        path: 'countyAcquisitionStatistics',
        name: '',
        component: () => import('@/views/projectOa/myProject/myProject'),
        meta: {
          title: '历史项目',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户', , 'oa管理员']
        }
      },

      {
        path: 'jwEdit1',
        name: '',
        component: () => import('@/views/projectOa/myProject/myProject'),
        meta: {
          title: '人员工时统计',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']

        }
      }

    ]
  },

  {
    path: '/meeting',
    component: Layout,
    name: 'meeting',
    meta: {
      title: '会议',
      icon: 'meeting'
      , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']
    },
    children: [

      {
        path: 'meetingRoom',
        name: '',
        component: () => import('@/views/meeting/meetingRoom'),
        meta: {
          title: '会议室管理',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']

        }
      },

      {
        path: 'meetingApply',
        name: '',
        component: () => import('@/views/meeting/meetingApply'),
        meta: {
          title: '会议室申请',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']

        }
      },
      {
        path: 'meetingTalking',
        name: '',
        component: () => import('@/views/meeting/meetingTalking'),
        meta: {
          title: '会议记录',
          icon: 'arrow-right'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']

        }
      }

    ]
  },

  //客户

  {
    path: '/customer',
    component: Layout,
    name: 'customer',
    meta: {
      title: '客户&供应商',
      icon: 'customer'
      , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']
    },
    children: [

      {
        path: 'customerManage',
        name: '',
        component: () => import('@/views/customer/customerManage'),
        meta: {
          title: '客户管理',
          icon: 'customer1'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']

        }
      },

      {
        path: 'customerTalk',
        name: '',
        component: () => import('@/views/customer/customerTalk'),
        meta: {
          title: '客户访谈',
          icon: 'customer1'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']

        }
      },

      {
        path: 'supplierManage',
        name: '',
        component: () => import('@/views/customer/supplierManage'),
        meta: {
          title: '供应商管理',
          icon: 'supplier'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']

        }
      },

      {
        path: 'supplierTalk',
        name: '',
        component: () => import('@/views/customer/customerTalk'),
        meta: {
          title: '供应商访谈',
          icon: 'supplier'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']

        }
      },

    ]
  },

  // 用户管理
  {
    path: '/userManager',
    component: Layout,
    name: 'UserManager',
    meta: {
      title: '用户&部门',
      icon: 'users'
      , roles: ['oa管理员']

    },
    children: [
      {
        path: 'userShow',
        name: '',
        component: () => import('@/views/system-setting/user/userShow'),
        meta: {
          title: '员工风采展示',
          icon: 'arrow-right'
          , roles: ['oa管理员']
        }
      },
      {
        path: 'userManager',
        name: '',
        component: () => import('@/views/system-setting/user/user'),
        meta: {
          title: '企业员工管理',
          icon: 'arrow-right'
          , roles: ['oa管理员']
        }
      },
      {
        path: 'department',
        name: '',
        component: () => import('@/views/system-setting/department/department'),
        meta: {
          title: '部门映射管理',
          icon: 'arrow-right'
          , roles: ['oa管理员']
        }
      },
      {
        path: 'position',
        name: '',
        component: () => import('@/views/system-setting/position/position'),
        meta: {
          title: '部门职能管理',
          icon: 'arrow-right'
          , roles: ['oa管理员']
        }
      }
      ,{
        path: 'post',
        name: '',
        component: () => import('@/views/system-setting/post/post'),
        meta: {
          title: '岗位管理',
          icon: 'arrow-right'
          , roles: ['oa管理员']
        }
      }
      ,{
        path: 'rankManager',
        name: '',
        component: () => import('@/views/system-setting/rank/rank'),
        meta: {
          title: '职级管理',
          icon: 'arrow-right'
          , roles: ['oa管理员']
        }
      }

    ]
  },

  // 基础配置
  {
    path: '/baseConfig',
    component: Layout,
    name: 'BaseConfig',
    meta: {
      title: '设置',
      icon: 'set'
      , roles: ['oa管理员']
    },
    children: [
      {
        path: 'period4',
        name: '',
        component: () => import('@/views/logs/index'),
        meta: {
          title: '日志管理',
          icon: 'arrow-right'
        }
      },

      {
        path: 'reimbursementType',
        name: '',
        component: () => import('@/views/finance/reimbursementType'),
        meta: {
          title: '报销类型管理',
          icon: 'reimbursementType'
          , roles: ['言川一级用户', '言川二级用户', '言川三级用户', 'oa管理员']

        }
      },


      // {
      //   path: 'yearmanager',
      //   name: '',
      //   component: () => import('@/views/liucheng/index'),
      //   meta: {
      //     title: '流程测试',
      //     icon: 'arrow-right'
      //   }
      // },
      {
        path: 'loginmanager',
        name: '',
        component: () => import('@/views/loginmanager/index'),
        meta: {
          title: '登录统计',
          icon: 'arrow-right'
        }
      }

    ]
  }

]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
